package com.ljf.authority.infra.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ljf.authority.domain.repository.AuthorityBaseMenuPageMethodRepository;
import com.ljf.authority.dto.query.AuthorityBaseMenuPageMethodQuery;
import com.ljf.authority.infra.mapper.AuthorityBaseMenuPageMethodMapper;
import com.ljf.authority.model.AuthorityBaseMenuPageMethod;
import com.ljf.authority.vo.AuthorityBaseMenuPageMethodVO;
import com.ljf.common.exception.ServiceException;
import com.ljf.common.infra.repository.impl.BasisRepositoryImpl;
import com.ljf.common.utils.CollectionUtil;
import com.ljf.common.utils.StringUtil;
import org.springframework.stereotype.Component;

/**
 * 页面方法  数据访问接口实现
 *
 * @author LJF
 * @since 2024-11-22
 */
@Component
public class AuthorityBaseMenuPageMethodRepositoryImpl extends BasisRepositoryImpl<AuthorityBaseMenuPageMethodMapper, AuthorityBaseMenuPageMethod, AuthorityBaseMenuPageMethodQuery, AuthorityBaseMenuPageMethodVO> implements AuthorityBaseMenuPageMethodRepository {

    @Override
    protected QueryWrapper<AuthorityBaseMenuPageMethod> fillWrapper(AuthorityBaseMenuPageMethodQuery query, boolean sort) throws ServiceException {
        QueryWrapper<AuthorityBaseMenuPageMethod> wrapper = super.fillWrapper(query, sort);
        if (CollectionUtil.isNotEmpty(query.getCodeList())) {
            wrapper.in(AuthorityBaseMenuPageMethod.COL_CODE, query.getCodeList());
        }
        if (StringUtil.isNotEmpty(query.getCodeRightLike())) {
            wrapper.likeRight(AuthorityBaseMenuPageMethod.COL_CODE, query.getCodeRightLike());
        }
        return wrapper;
    }

}
